<template>
	<view>
		<!-- 搭配师背景占位图 -->
		<view class="header">
			<view class="back" :style="{marginTop: iStatusBarHeight + 'rpx'}">
				<view class="icon xiangqian" @click="back" hover-class="opacity7"></view>
				<view class="title">钱包</view>
				<view></view>
			</view>
		</view>

		<view class="box">
			<view class="title">
				<u-count-to :start-val="0.00" :end-val="integralBalance" :decimals="2" :font-size="42"></u-count-to>
				<view class="title2">可提现</view>
			</view>
			<view class="title">
				<u-count-to :start-val="0.00" :end-val="accountBalance" :decimals="2" :font-size="42"></u-count-to>
				<view class="title2">余额</view>
			</view>
			<view class="title">
				<u-count-to :start-val="0.00" :end-val="dueInMoney" :decimals="2" :font-size="42"></u-count-to>
				<view class="title2">待入账</view>
			</view>
		</view>

		<view v-if="isFreezeAccount === 1" style="padding: 5upx 30upx;">
			<u-alert-tips type="warning" title="您的账户已被冻结:" :description="freezeReason" v-if="isFreezeAccount === 0"></u-alert-tips>
		</view>

		<view style="font-size: 26upx;color: #666666;padding: 0 0 13upx 30upx;">陌搭服务</view>

		<!-- 操作栏 -->
		<view class="bottom_list">
			<view class="row" hover-class="opacity7" @click="toPage('/pages/stylist/withdraw')">
				<view class="title">
					<image src="../../static/img/stylist/waller_02.png" mode="aspectFit"></image>
					<span>提现</span>
				</view>
				<view class="right">
					<view class="icon xiangyou"></view>
				</view>
			</view>
			<view class="row" hover-class="opacity7" @click="toPage('/pages/stylist/bill')">
				<view class="title">
					<image src="../../static/img/stylist/waller_03.png" mode="aspectFit"></image>
					<span>账单</span>
				</view>
				<view class="right">
					<view class="icon xiangyou"></view>
				</view>
			</view>
		</view>

		<!-- 占位 -->
		<view class="place-bottom"></view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				accountBalance: 0.00,
				dueInMoney: 0.00,
				integralBalance: 0.00,
				isFreezeAccount: 0, // 0:正常, 1:冻结
				freezeReason: '',
				iStatusBarHeight: 0
			}
		},
		onPullDownRefresh() {
			this.searchWallet()
		},
		onLoad() {
			this.searchWallet()
		},
		onShow() {
			// 每次進入刷新我的錢包
			this.searchWallet()
		},
		mounted() {
			this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight
			console.log(this.iStatusBarHeight)
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			toPage(url) {
				uni.navigateTo({
					url: url
				})
			},
			searchWallet() {
				this.$u.api.getMyAssets().then(res => {
					uni.stopPullDownRefresh();
					if (res.code === 200) {
						this.accountBalance = res.data.accountBalance
						this.dueInMoney = res.data.dueInMoney
						this.integralBalance = res.data.integralBalance
						this.isFreezeAccount = res.data.isFreezeAccount
						this.freezeReason = res.data.freezeReason
					}
				})
			},

		}
	}
</script>
<style lang="scss">
	page {
		position: relative;
		background-color: #F7F8FA;
	}

	.header {
		width: 100%;
		height: 328upx;
		justify-content: flex-start;
		align-items: center;
		border-radius: 0px 0px 28upx 28upx;
		background: linear-gradient(159deg, #242422 0%, #555555 100%);
		.back {
			position: absolute;
			height: 36upx;
			top: 66upx;
			padding: 0 30upx;
			width: calc(100vw - 60upx);
			z-index: 20;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.icon {
				color: white;
				font-size: 20px;
			}
		}

		.title {
			color: white;
			font-size: 36upx;
			font-weight: 500;
		}

		.icon-btn {
			width: 120upx;
			height: 60upx;
			flex-shrink: 0;
			display: flex;

			.icon {
				color: #fff;
				width: 60upx;
				height: 60upx;
				display: flex;
				justify-content: flex-end;
				align-items: center;
				font-size: 42upx;
			}
		}
	}

	.box {
		width: 690upx;
		height: 228upx;
		margin: -105upx auto 50upx auto;
		padding: 70upx 66upx;
		background: white;
		border-radius: 12upx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.title {
			font-size: 42upx;
			color: #333333;
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		.title2 {
			font-size: 28upx;
			color: #666666;
			padding-top: 32upx;
		}
	}

	.bottom_list {
		background-color: #fff;

		.row {
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: #fff;
			padding: 32upx 30upx 32upx 30upx;

			.title {
				font-size: 26upx;
				color: #666666;
				display: flex;
				align-items: center;

				image {
					width: 58upx;
					height: 55upx;
					margin-right: 20upx;
				}
			}

			.right {
				display: flex;
				align-items: center;
				color: #999;

				.icon {
					width: 42upx;
					color: #333333;
					font-size: 29upx;
				}
			}

		}
	}
</style>
